package com.session04.homework;

public class Poker implements Comparable<Poker> {
    private String color;
    private String num;

    private int colorValue;
    private int numValue;

    public Poker() {

    }

    public Poker(String color, String num) {
        this.color = color;
        this.num = num;
        this.generateValue();
    }

    private void generateValue() {
        switch (this.color) {
            case "♠":
                this.colorValue = 400;
                break;
            case "♥":
                this.colorValue = 300;
                break;
            case "♣":
                this.colorValue = 200;
                break;
            case "♦":
                this.colorValue = 100;
                break;
            default:
                this.colorValue = 500;
                break;
        }

        switch (this.num) {
            case "大🃏":
                this.numValue = 17;
                break;
            case "小🃏":
                this.numValue = 16;
                break;
            case "2":
                this.numValue = 15;
                break;
            case "A":
                this.numValue = 14;
                break;
            case "K":
                this.numValue = 13;
                break;
            case "Q":
                this.numValue = 12;
                break;
            case "J":
                this.numValue = 11;
                break;
            default:
                this.numValue = Integer.parseInt(this.num);
                break;
        }
    }

    public String getColor() {
        return color;
    }

    public void setColor(String color) {
        this.color = color;
    }

    public String getNum() {
        return num;
    }

    public void setNum(String num) {
        this.num = num;
    }

    public int getColorValue() {
        return colorValue;
    }

    public void setColorValue(int colorValue) {
        this.colorValue = colorValue;
    }

    public int getNumValue() {
        return numValue;
    }

    public void setNumValue(int numValue) {
        this.numValue = numValue;
    }

    @Override
    public String toString() {
        return this.color + this.num;
    }

    @Override
    public int compareTo(Poker o) {
        if(this.colorValue > o.colorValue){
            return -1;
        }else if(this.colorValue < o.colorValue){
            return 1;
        }else{
            if(this.numValue > o.numValue){
                return -1;
            }else if(this.numValue < o.numValue){
                return 1;
            }
        }
        return 0;
    }
}
